package com.example.project.manageController;


import com.example.project.dao.CarDAO;
import com.example.project.pojo.Car;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.util.List;

@Controller
    @RequestMapping("manage")
    public class ManageFindAllCarController {
        @RequestMapping("findcar")
        public String findcar(Model model)
        {
            CarDAO carDAO = new CarDAO();
            List<Car> carList = carDAO.findCarById();
            //从MySQL数据库中间查出数据
            model.addAttribute("carList",carList);
            return "manage/manageFindCar";
        }

        @RequestMapping("deletecar")
        @ResponseBody
        public void  deletecar(HttpServletRequest request)
        {

            //获取车牌号
            String strId = request.getParameter("id");


            CarDAO carDAO = new CarDAO();

            carDAO.deleteCarByLicense(strId);

            System.out.println(strId);

        }
}

